package k.dao.base;

import k.dto.Org;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
/**
 * Created by sure
 */
@Component
public class OrgDao {
    private String sql;
    @Autowired
    BaseDao baseDao;

    public List<Org> findAll(){
        sql = "SELECT * FROM `org`";
        return baseDao.query(sql,Org.class);
    }

    public void insertOrg(Org org){
        sql = "INSERT INTO `bitserver`.`org` ( `org_name`) VALUES ( :org_name)";
        baseDao.insert(sql,org);
    }
    public void upOrg(Org org){
        sql = "UPDATE `bitserver`.`org` SET  `org_name`= :org_name WHERE (`org_id`=:org_id)  ";
        baseDao.update(sql,org);
    }

    public  Org querybyId(String org_id){
        sql = "select * from org where org_id = ?";
        return baseDao.queryById(sql,Org.class,org_id);
    }

    public void  del(String org_id){
        sql = "delete from org  where org_id = ? " ;
        Integer n = baseDao.delete(sql,new Object[]{org_id});
    }
}
